import AccessTokenDao from '../db/redis'

class AccessTokenService {
  /* 存储用户信息 */
  async setAccessToken(key, value) {
    const res = await AccessTokenDao.setData(key, value)
    console.log('测试存储:', res)
  }

  /* 获取用户信息 */
  async getAccessToken(key) {
    const res = await AccessTokenDao.getData(key)
    console.log('测试获取:', res)
  }

  /* 重置存储用户信息过期时间 */
  async resetAccessToken(key, expire) {
    try {
      const res = await AccessTokenDao.resetExpirationTime(key, expire)
      console.log('测试重置:', res)
    } catch (error) {
      console.log('测试error:', error)
    }
  }

  /* 移除存储的用户信息 */
  async removeAccessToken(key) {
    try {
      const res = await AccessTokenDao.removeData(key)
      console.log('测试移除:', res)
    } catch (error) {
      console.log('测试error:', error)
    }
  }
}
export default new AccessTokenService()
